//
//  EightPicView.m
//  TravelFirst
//
//  Created by lanou3g on 15/9/19.
//  Copyright (c) 2015年 吴娅君. All rights reserved.
//

#import "EightPicView.h"

@implementation EightPicView

-(instancetype)initpic:(NSArray *)pic title:(NSArray *)title target:(id)target action:(SEL)action{

        int temp=0;
        for(int j = 0; j < 2; j++){
            for(int i = 0; i <pic.count / 2; i++){
                UIButton *view=[[UIButton alloc]initWithFrame:CGRectMake(i * (kWidth/4), j * (kWidth/4 ), kWidth/4, kWidth/4 )];
                view.tag=temp+10;
                view.layer.borderWidth = 1;
                [view addTarget:target action:action forControlEvents:(UIControlEventTouchUpInside)];
                view.backgroundColor=[UIColor whiteColor];
                view.layer.borderColor=[UIColor colorWithRed:180%256/255.0 green:201%256/255.0 blue:207%256/255.0 alpha:1].CGColor;
                UIImageView *EightPic = [[UIImageView alloc] initWithFrame:CGRectMake(view.frame.size.width/6, 0, kWidth/6, kWidth/6) ];
                EightPic.image = [UIImage imageNamed:pic[temp]];
                EightPic.layer.masksToBounds = YES;
                
                UILabel *titleLable = [[UILabel alloc] initWithFrame:CGRectMake(0, kWidth/6 , kWidth/4, 20)];
                titleLable.font=[UIFont boldSystemFontOfSize:12];
                titleLable.text = title[temp];
                titleLable.textAlignment = 1;
                
                [view addSubview:titleLable];
                [view addSubview:EightPic];
                [self addSubview:view];
                temp++;
            }
        }

    return self;
}

@end
